// todo start
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter);

const routes = [
  {
    path: "",
    redirect: "/recommend"
  },
    {
        path: '/recommend',
        name: 'recommend',
        component: ()=> import("../views/recommend.vue"),
        meta: {
            title: '财经资讯'
        }
    }, 
    {
        path: '/center',
        name: 'center',
        component: ()=> import("../views/center.vue"),
        children: [
          {
            path: "",
            redirect: "/center/xgsg"
          },
          {
            path: "/center/xgss",
            component: ()=> import("../views/xgss.vue"),
          },
          {
            path: "/center/xgsg",
            component: ()=> import("../views/xgsg.vue"),
          }
        ],  
        meta: {
          title: '新股中心'
      }
    }, 
    {
      path: '/calendar',
      name: 'calendar',
      component: ()=> import("../views/calendar.vue"),
      meta: {
          title: '财经日历'
      }
  }, 
  {
    path: '/recommend/setBooks',
    name: 'setBooks',
    component: ()=> import("../views/setBooks.vue"),
    meta: {
        title: '财经推荐'
    }
}, 

];
const router = new VueRouter({
    linkActiveClass: 'active',
    base: process.env.BASE_URL,
    routes
});
//路由后置钩子
router.afterEach((to, from) => {

    //设置头部标题
    if (to.meta.title) document.title = to.meta.title;
});

export default router;